<?php

namespace app\admin\controller;

use think\Controller;
use think\Request;

class Keyword extends Base
{
    /**
     * 显示资源列表
     *
     * @return \think\Response
     */
    public function index()
    {
        $list=db('search')->select();
        $this->assign('list',$list);
        return $this->fetch();
    }
    /**
     * 保存新建的资源
     *
     * @param  \think\Request  $request
     * @return \think\Response
     */
    public function save(Request $request)
    {
        $data=input();
        $keyword = model( 'keyword' );
        $list = $keyword->creat( $data );
        if( $list) {
            $this->success( '添加成功' , url( 'keyword/index' ) );
        } else {
            $this->error( '添加失败' );
        }
    }
    /**
     * 删除指定资源
     *
     * @param  int  $id
     * @return \think\Response
     */
    public function delete($id)
    {
        $list=db('search')->where(['id'=>$id])->delete();
        if( $list) {
            $this->success( '删除成功' , url( 'keyword/index' ) );
        } else {
            $this->error( '删除失败' );
        }
    }
}
